home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / ftn / mp.z / mp
Encoding:
Text File  |  1998-10-30  |  86.2 KB  |  1,849 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  71.  
  72.  
  73.  
  74. NNNNAAAAMMMMEEEE
  75.      mp: mp_block, mp_blocktime, mp_create, mp_destroy, mp_my_threadnum,
  76.      mp_numthreads, mp_set_numthreads, mp_setup, mp_unblock, mp_setlock,
  77.      mp_suggested_numthreads,mp_unsetlock, mp_barrier, mp_in_doacross_loop,
  78.      mp_set_slave_stacksize - FORTRAN multiprocessing utility routines
  79.  
  80. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  81.      ssssuuuubbbbrrrroooouuuuttttiiiinnnneeee mmmmpppp____bbbblllloooocccckkkk(((())))
  82.  
  83.      ssssuuuubbbbrrrroooouuuuttttiiiinnnneeee mmmmpppp____uuuunnnnbbbblllloooocccckkkk(((())))
  84.  
  85.      ssssuuuubbbbrrrroooouuuuttttiiiinnnneeee mmmmpppp____bbbblllloooocccckkkkttttiiiimmmmeeee((((iiiitttteeeerrrrssss))))
  86.      iiiinnnntttteeeeggggeeeerrrr iiiitttteeeerrrrssss
  87.  
  88.      ssssuuuubbbbrrrroooouuuuttttiiiinnnneeee mmmmpppp____sssseeeettttuuuupppp(((())))
  89.  
  90.      ssssuuuubbbbrrrroooouuuuttttiiiinnnneeee mmmmpppp____ccccrrrreeeeaaaatttteeee((((nnnnuuuummmm))))
  91.      iiiinnnntttteeeeggggeeeerrrr nnnnuuuummmm
  92.  
  93.      ssssuuuubbbbrrrroooouuuuttttiiiinnnneeee mmmmpppp____ddddeeeessssttttrrrrooooyyyy(((())))
  94.  
  95.      iiiinnnntttteeeeggggeeeerrrr ffffuuuunnnnccccttttiiiioooonnnn mmmmpppp____nnnnuuuummmmtttthhhhrrrreeeeaaaaddddssss(((())))
  96.  
  97.      ssssuuuubbbbrrrroooouuuuttttiiiinnnneeee mmmmpppp____sssseeeetttt____nnnnuuuummmmtttthhhhrrrreeeeaaaaddddssss((((nnnnuuuummmm))))
  98.      iiiinnnntttteeeeggggeeeerrrr nnnnuuuummmm
  99.  
  100.      iiiinnnntttteeeeggggeeeerrrr ffffuuuunnnnccccttttiiiioooonnnn mmmmpppp____mmmmyyyy____tttthhhhrrrreeeeaaaaddddnnnnuuuummmm(((())))
  101.  
  102.      iiiinnnntttteeeeggggeeeerrrr ffffuuuunnnnccccttttiiiioooonnnn mmmmpppp____iiiissss____mmmmaaaasssstttteeeerrrr(((())))
  103.  
  104.      ssssuuuubbbbrrrroooouuuuttttiiiinnnneeee mmmmpppp____sssseeeettttlllloooocccckkkk(((())))
  105.  
  106.      iiiinnnntttteeeeggggeeeerrrr ffffuuuunnnnccccttttiiiioooonnnn mmmmpppp____ssssuuuuggggggggeeeesssstttteeeedddd____nnnnuuuummmmtttthhhhrrrreeeeaaaaddddssss((((nnnnuuuummmm))))
  107.      iiiinnnntttteeeeggggeeeerrrr nnnnuuuummmm
  108.  
  109.      ssssuuuubbbbrrrroooouuuuttttiiiinnnneeee mmmmpppp____uuuunnnnsssseeeettttlllloooocccckkkk(((())))
  110.  
  111.      ssssuuuubbbbrrrroooouuuuttttiiiinnnneeee mmmmpppp____bbbbaaaarrrrrrrriiiieeeerrrr(((())))
  112.  
  113.      llllooooggggiiiiccccaaaallll ffffuuuunnnnccccttttiiiioooonnnn mmmmpppp____iiiinnnn____ddddooooaaaaccccrrrroooossssssss____lllloooooooopppp(((())))
  114.  
  115.      ssssuuuubbbbrrrroooouuuuttttiiiinnnneeee mmmmpppp____sssseeeetttt____ssssllllaaaavvvveeee____ssssttttaaaacccckkkkssssiiiizzzzeeee((((ssssiiiizzzzeeee))))
  116.      iiiinnnntttteeeeggggeeeerrrr ssssiiiizzzzeeee
  117.  
  118.  
  119. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  120.      These routines give some measure of control over the parallelism used in
  121.      FORTRAN jobs.  They should not be needed by most users, but will help to
  122.      tune specific applications.
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  137.  
  138.  
  139.  
  140.      _m_p__b_l_o_c_k puts all slave threads to sleep via _b_l_o_c_k_p_r_o_c(2).  This frees
  141.      the processors for use by other jobs.  This is useful if it is known that
  142.      the slaves will not be needed for some time, and the machine is being
  143.      shared by several users.  Calls to _m_p__b_l_o_c_k may not be nested; a warning
  144.      is issued if an attempt to do so is made.
  145.  
  146.      _m_p__u_n_b_l_o_c_k wakes up the slave threads that were previously blocked via
  147.      _m_p__b_l_o_c_k.  It is an error to unblock threads that are not currently
  148.      blocked; a warning is issued if an attempt is made to do so.
  149.  
  150.      It is not necessary to explicitly call _m_p__u_n_b_l_o_c_k.  When a FORTRAN
  151.      parallel region is entered, a check is made, and if the slaves are
  152.      currently blocked, a call is made to _m_p__u_n_b_l_o_c_k automatically.
  153.  
  154.      _m_p__b_l_o_c_k_t_i_m_e controls the amount of time a slave thread waits for work
  155.      before giving up.  When enough time has elapsed, the slave thread blocks
  156.      itself.  This automatic blocking is independent of the user level
  157.      blocking provided by the _m_p__b_l_o_c_k/_m_p__u_n_b_l_o_c_k calls.  Slave threads that
  158.      have blocked themselves will be automatically unblocked upon entering a
  159.      parallel region.  The argument to _m_p__b_l_o_c_k_t_i_m_e is the number of times to
  160.      spin in the wait loop.  By default, it is set to 10,000,000.  This takes
  161.      about .25 seconds on a 200MHz processor.  As a special case, an argument
  162.      of 0 disables the automatic blocking, and the slaves will spin wait
  163.      without limit.  The environment variable _M_P__B_L_O_C_K_T_I_M_E may be set to an
  164.      integer value.  It acts like an implicit call to _m_p__b_l_o_c_k_t_i_m_e during
  165.      program startup.
  166.  
  167.      _m_p__d_e_s_t_r_o_y deletes the slave threads.  They are stopped by forcing them
  168.      to call _e_x_i_t(2).  In general, doing this is discouraged.  _m_p__b_l_o_c_k can be
  169.      used in most cases.
  170.  
  171.      _m_p__c_r_e_a_t_e creates and initializes threads.  It creates enough threads so
  172.      that the total number is equal to the argument.  Since the calling thread
  173.      already counts as one, _m_p__c_r_e_a_t_e will create one less than its argument
  174.      in new slave threads.
  175.  
  176.      _m_p__s_e_t_u_p also creates and initializes threads.  It takes no arguments.
  177.      It simply calls _m_p__c_r_e_a_t_e using the current default number of threads.
  178.      Unless otherwise specified, the default number is equal to the number of
  179.      cpu's currently on the machine, or 8, whichever is less.  If the user has
  180.      not called either of the thread creation routines already, then _m_p__s_e_t_u_p
  181.      is invoked automatically when the first parallel region is entered.  If
  182.      the environment variable _M_P__S_E_T_U_P is set, then _m_p__s_e_t_u_p is called during
  183.      FORTRAN initialization, before any user code is executed.
  184.  
  185.      _m_p__n_u_m_t_h_r_e_a_d_s returns the number of threads that would participate in an
  186.      immediately following parallel region.  If the threads have already been
  187.      created, then it returns the current number of threads.  If the threads
  188.      have not been created, then it returns the current default number of
  189.      threads.  The count includes the master thread.  Knowing this count can
  190.      be useful in optimizing certain kinds of parallel loops by hand, but this
  191.      function has the side-effect of freezing the number of threads to the
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  203.  
  204.  
  205.  
  206.      returned value.  As a result, this routine should be used sparingly.  To
  207.      determine the number of threads without this side-effect, see the
  208.      description of _m_p__s_u_g_g_e_s_t_e_d__n_u_m_t_h_r_e_a_d_s below.
  209.  
  210.      _m_p__s_e_t__n_u_m_t_h_r_e_a_d_s sets the current default number of threads to the
  211.      specified value.  Note that this call does not directly create the
  212.      threads, it only specifies the number that a subsequent _m_p__s_e_t_u_p call
  213.      should use.  If the environment variable _M_P__S_E_T__N_U_M_T_H_R_E_A_D_S is set, it
  214.      acts like an implicit call to _m_p__s_e_t__n_u_m_t_h_r_e_a_d_s during program startup.
  215.      For convenience when operating among several machines with different
  216.      numbers of cpus, _M_P__S_E_T__N_U_M_T_H_R_E_A_D_S may be set to an expression involving
  217.      integer literals, the binary operators + and -, the binary functions min
  218.      and max, and the special symbolic value _A_L_L which stands for "the total
  219.      number of available cpus on the current machine."  Thus, something simple
  220.      like
  221.                  setenv MP_SET_NUMTHREADS 7
  222.      would set the number of threads to seven.  This may be a fine choice on
  223.      an 8 cpu machine, but would be very bad on a 4 cpu machine.  Instead, use
  224.      something like
  225.                  setenv MP_SET_NUMTHREADS "max(1,all-1)"
  226.      which sets the number of threads to be one less than the number of cpus
  227.      on the current machine (but always at least one).  If your configuration
  228.      includes some machines with large numbers of cpus, setting an upper bound
  229.      is a good idea.  Something like:
  230.                  setenv MP_SET_NUMTHREADS "min(all,4)"
  231.      will request (no more than) 4 cpus.
  232.  
  233.      For compatibility with earlier releases, _N_U_M__T_H_R_E_A_D_S is supported as a
  234.      synonym for _M_P__S_E_T__N_U_M_T_H_R_E_A_D_S.
  235.  
  236.      _m_p__m_y__t_h_r_e_a_d_n_u_m returns an integer between 0 and _n-1 where _n is the value
  237.      returned by _m_p__n_u_m_t_h_r_e_a_d_s.  The master process is always thread 0.  This
  238.      is occasionally useful for optimizing certain kinds of loops by hand.
  239.  
  240.      _m_p__i_s__m_a_s_t_e_r returns 1 if called by the master process, 0 otherwise.
  241.  
  242.      _m_p__s_e_t_l_o_c_k provides convenient (though limited) access to the locking
  243.      routines.  The convenience is that no set up need be done; it may be
  244.      called directly without any preliminaries.  The limitation is that there
  245.      is only one lock.  It is analogous to the _u_s_s_e_t_l_o_c_k(3P) routine, but it
  246.      takes no arguments and does not return a value.  This is useful for
  247.      serializing access to shared variables (e.g.  counters) in a parallel
  248.      region.  Note that it will frequently be necessary to declare those
  249.      variables as VOLATILE to ensure that the optimizer does not assign them
  250.      to a register.
  251.  
  252.      _m_p__s_u_g_g_e_s_t_e_d__n_u_m_t_h_r_e_a_d_s uses the supplied value as a hint about how many
  253.      threads to use in subsequent parallel regions, and returns the previous
  254.      value of the number of threads to be employed in parallel regions. It
  255.      does not affect currently executing parallel regions, if any. The
  256.      implementation may ignore this hint depending on factors such as overall
  257.      system load.  This routine may also be called with the value 0, in which
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  269.  
  270.  
  271.  
  272.      case it simply returns the number of threads to be employed in parallel
  273.      regions without the side-effect present in _m_p__n_u_m_t_h_r_e_a_d_s.
  274.  
  275.      _m_p__u_n_s_e_t_l_o_c_k is the companion routine for _m_p__s_e_t_l_o_c_k.  It also takes no
  276.      arguments and does not return a value.
  277.  
  278.      _m_p__b_a_r_r_i_e_r provides a simple interface to a single _b_a_r_r_i_e_r(3P).  It may
  279.      be used inside a parallel loop to force a barrier synchronization to
  280.      occur among the parallel threads.  The routine takes no arguments,
  281.      returns no value, and does not require any initialization.
  282.  
  283.      _m_p__i_n__d_o_a_c_r_o_s_s__l_o_o_p answers the question "am I currently executing inside
  284.      a parallel loop."  This is needful in certain rare situations where you
  285.      have an external routine that can be called both from inside a parallel
  286.      loop and also from outside a parallel loop, and the routine must do
  287.      different things depending on whether it is being called in parallel or
  288.      not.
  289.  
  290.      _m_p__s_e_t__s_l_a_v_e__s_t_a_c_k_s_i_z_e sets the stacksize (in bytes) to be used by the
  291.      slave processes when they are created (via _s_p_r_o_c_s_p(2)).  The default size
  292.      is 16MB.  Note that slave processes only allocate their local data onto
  293.      their stack, shared data (even if allocated on the master's stack) is not
  294.      counted.
  295.  
  296.  
  297.      DDDDiiiirrrreeeeccccttttiiiivvvveeeessss
  298.  
  299.      The MIPSpro Fortran 77 compiler allows you to apply the capabilities of a
  300.      Silicon Graphics multiprocessor computer to the execution of a single
  301.      job. By coding a few simple directives, the compiler splits the job into
  302.      concurrently executing pieces, thereby decreasing the wall-clock run time
  303.      of the job.
  304.  
  305.      Directives enable, disable, or modify a feature of the compiler.
  306.      Essentially, directives are command line options specified within the
  307.      input file instead of on the command line. Unlike command line options,
  308.      directives have no default setting. To invoke a directive, you must
  309.      either toggle it on or set a desired value for its level.
  310.  
  311.      Directives placed on the first line of the input file are called global
  312.      directives. The compiler interprets them as if they appeared at the top
  313.      of each program unit in the file. Use global directives to ensure that
  314.      the program is compiled with the correct command line options. Directives
  315.      appearing anywhere else in the file apply only until the end of the
  316.      current program unit. The compiler resets the value of the directive to
  317.      the global value at the start of the next program unit. (Set the global
  318.      value using a command line option or a global directive.)
  319.  
  320.      Some command line options act like global directives. Other command line
  321.      options override directives. Many directives have corresponding command
  322.      line options. If you specify conflicting settings in the command line and
  323.      a directive, the compiler chooses the most restrictive setting. For
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  335.  
  336.  
  337.  
  338.      Boolean options, if either the directive or the command line has the
  339.      option turned off, it is considered off. For options that require a
  340.      numeric value, the compiler uses the minimum of the command line setting
  341.      and the directive setting.
  342.  
  343.      The Fortran compiler accepts directives that cause it to generate code
  344.      that can be run in parallel. The compiler directives look like Fortran
  345.      comments: they begin with a C in column one. If multiprocessing is not
  346.      turned on, these statements are treated as comments. This allows the
  347.      identical source to be compiled with a single-processing compiler or by
  348.      Fortran without the multiprocessing option. The directives are
  349.      distinguished by having a $ as the second character. The following
  350.      directives are supported:
  351.  
  352.      CCCC$$$$DDDDOOOOAAAACCCCRRRROOOOSSSSSSSS,,,, CCCC$$$$&&&&,,,, CCCC$$$$,,,, CCCC$$$$MMMMPPPP____SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE,,,, CCCC$$$$CCCCHHHHUUUUNNNNKKKK,,,, and CCCC$$$$CCCCOOOOPPPPYYYYIIIINNNN....
  353.  
  354.  
  355.  
  356.      CCCC$$$$DDDDOOOOAAAACCCCRRRROOOOSSSSSSSS
  357.  
  358.      The essential compiler directive for multiprocessing is CCCC$$$$DDDDOOOOAAAACCCCRRRROOOOSSSSSSSS....  This
  359.      directive directs the compiler to generate special code to run iterations
  360.      of a DO loop in parallel. The CCCC$$$$DDDDOOOOAAAACCCCRRRROOOOSSSSSSSS directive applies only to the
  361.      next statement (which must be a DO loop). The Fortran compiler does not
  362.      support direct nesting of CCCC$$$$DDDDOOOOAAAACCCCRRRROOOOSSSSSSSS loops. The CCCC$$$$DDDDOOOOAAAACCCCRRRROOOOSSSSSSSS directive has
  363.      the form
  364.  
  365.      C$DOACROSS [clause [ [,] clause ...]
  366.  
  367.      where valid values for the optional clause are
  368.  
  369.             [IF (logical_expression)]
  370.  
  371.             [{LOCAL | PRIVATE} (item[,item ...])]
  372.  
  373.             [{SHARE | SHARED} (item[,item ...])]
  374.  
  375.             [{LASTLOCAL | LAST LOCAL} (item[,item ...])]
  376.  
  377.             [REDUCTION (item[,item ...])]
  378.  
  379.             [MP_SCHEDTYPE=mode ]
  380.  
  381.             [CHUNK=integer_expression]
  382.  
  383.      The preferred form of the directive uses the optional commas between
  384.      clauses. This section discusses the meaning of each clause.
  385.  
  386.  
  387.          IIIIFFFF
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  401.  
  402.  
  403.  
  404.          The IIIIFFFF clause determines whether the loop is actually executed in
  405.          parallel. If the logical expression is TRUE, the loop is executed in
  406.          parallel. If the expression is FALSE, the loop is executed serially.
  407.  
  408.  
  409.          LLLLOOOOCCCCAAAALLLL,,,, SSSSHHHHAAAARRRREEEE,,,, LLLLAAAASSSSTTTTLLLLOOOOCCCCAAAALLLL
  410.  
  411.          These clauses specify lists of variables used within parallel loops.
  412.          A variable can appear in only one of these lists. To make the task of
  413.          writing these lists easier, there are several defaults. The loop-
  414.          iteration variable is LLLLAAAASSSSTTTTLLLLOOOOCCCCAAAALLLL by default. All other variables are
  415.          SSSSHHHHAAAARRRREEEE by default.
  416.  
  417.          LLLLOOOOCCCCAAAALLLL Specifies variables that are local to each process. If a
  418.          variable is declared as LOCAL, each iteration of the loop is given
  419.          its own uninitialized copy of the variable. You can declare a
  420.          variable as LLLLOOOOCCCCAAAALLLL if its value does not depend on any other iteration
  421.          of the loop and if its value is used only within a single iteration.
  422.          In effect the LLLLOOOOCCCCAAAALLLL variable is just temporary; a new copy can be
  423.          created in each loop iteration without changing the final answer. The
  424.          name LLLLOOOOCCCCAAAALLLL is preferred over PPPPRRRRIIIIVVVVAAAATTTTEEEE.... SSSSHHHHAAAARRRREEEE Specifies variables that
  425.          are shared across all processes. If a variable is declared as SSSSHHHHAAAARRRREEEE,,,,
  426.          all iterations of the loop use the same copy of the variable. You can
  427.          declare a variable as SSSSHHHHAAAARRRREEEE if it is only read (not written) within
  428.          the loop or if it is an array where each iteration of the loop uses a
  429.          different element of the array. The name SSSSHHHHAAAARRRREEEE is preferred over
  430.          SSSSHHHHAAAARRRREEEEDDDD....
  431.  
  432.          LLLLAAAASSSSTTTTLLLLOOOOCCCCAAAALLLL Specifies variables that are local to each process.Unlike
  433.          with the LLLLOOOOCCCCAAAALLLL clause, the compiler saves only the value of the
  434.          logically last iteration of the loop when it exits. The name
  435.          LLLLAAAASSSSTTTTLLLLOOOOCCCCAAAALLLL is preferred over LLLLAAAASSSSTTTT LLLLOOOOCCCCAAAALLLL....
  436.  
  437.          LLLLOOOOCCCCAAAALLLL is a little faster than LLLLAAAASSSSTTTTLLLLOOOOCCCCAAAALLLL,,,, so if you do not need the
  438.          final value, it is good practice to put the DO loop index variable
  439.          into the LLLLOOOOCCCCAAAALLLL list, although this is not required.
  440.  
  441.          Only variables can appear in these lists. In particular, COMMON
  442.          blocks cannot appear in a LLLLOOOOCCCCAAAALLLL list.  The SSSSHHHHAAAARRRREEEE,,,, LLLLOOOOCCCCAAAALLLL,,,, and
  443.          LLLLAAAASSSSTTTTLLLLOOOOCCCCAAAALLLL lists give only the names of the variables. If any member
  444.          of the list is an array, it is listed without any subscripts.
  445.  
  446.  
  447.          RRRREEEEDDDDUUUUCCCCTTTTIIIIOOOONNNN
  448.  
  449.          The RRRREEEEDDDDUUUUCCCCTTTTIIIIOOOONNNN clause specifies variables involved in a reduction
  450.          operation. In a reduction operation, the compiler keeps local copies
  451.          of the variables and combines them when it exits the loop. An element
  452.          of the RRRREEEEDDDDUUUUCCCCTTTTIIIIOOOONNNN list must be an individual variable (also called a
  453.          scalar variable) and cannot be an array. However, it can be an
  454.          individual element of an array. In a RRRREEEEDDDDUUUUCCCCTTTTIIIIOOOONNNN clause, it would
  455.          appear in the list with the proper subscripts.
  456.  
  457.  
  458.  
  459.                                                                         PPPPaaaaggggeeee 7777
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  467.  
  468.  
  469.  
  470.          One element of an array can be used in a reduction operation, while
  471.          other elements of the array are used in other ways. To allow for
  472.          this, if an element of an array appears in the RRRREEEEDDDDUUUUCCCCTTTTIIIIOOOONNNN list, the
  473.          entire array can also appear in the SSSSHHHHAAAARRRREEEE list.
  474.  
  475.          The four types of reductions supported are _s_u_m(+), _p_r_o_d_u_c_t(*), _m_i_n(),
  476.          and _m_a_x(). Note that _m_i_n(_m_a_x) reductions must use the _m_i_n(_m_a_x)
  477.          intrinsic functions to be recognized correctly.
  478.  
  479.          The compiler confirms that the reduction expression is legal by
  480.          making some simple checks. The compiler does not, however, check all
  481.          statements in the DO loop for illegal reductions. You must ensure
  482.          that the reduction variable is used correctly in a reduction
  483.          operation.
  484.  
  485.  
  486.          CCCCHHHHUUUUNNNNKKKK,,,, MMMMPPPP____SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE
  487.  
  488.          The CCCCHHHHUUUUNNNNKKKK and MMMMPPPP____SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE clauses affect the way the compiler
  489.          schedules work among the participating tasks in a loop. These clauses
  490.          do not affect the correctness of the loop. They are useful for tuning
  491.          the performance of critical loops.
  492.  
  493.          For the MMMMPPPP____SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE====mmmmooooddddeeee clause, mode can be one of the following:
  494.  
  495.          [SIMPLE | STATIC]
  496.  
  497.          [DYNAMIC]
  498.  
  499.          [INTERLEAVE INTERLEAVED]
  500.  
  501.          [GUIDED GSS]
  502.  
  503.          [RUNTIME]
  504.  
  505.          You can use any or all of these modes in a single program. The CCCCHHHHUUUUNNNNKKKK
  506.          clause is valid only with the DDDDYYYYNNNNAAAAMMMMIIIICCCC and IIIINNNNTTTTEEEERRRRLLLLEEEEAAAAVVVVEEEE modes. SSSSIIIIMMMMPPPPLLLLEEEE,,,,
  507.          DDDDYYYYNNNNAAAAMMMMIIIICCCC,,,, IIIINNNNTTTTEEEERRRRLLLLEEEEAAAAVVVVEEEE,,,, GGGGSSSSSSSS,,,, and RRRRUUUUNNNNTTTTIIIIMMMMEEEE are the preferred names for
  508.          each mode.
  509.  
  510.          The simple method (MMMMPPPP____SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE====SSSSIIIIMMMMPPPPLLLLEEEE) divides the iterations among
  511.          processes by dividing them into contiguous pieces and assigning one
  512.          piece to each process.
  513.  
  514.          In dynamic scheduling (MMMMPPPP____SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE====DDDDYYYYNNNNAAAAMMMMIIIICCCC) the iterations are
  515.          broken into pieces the size of which is specified with the CCCCHHHHUUUUNNNNKKKK
  516.          clause. As each process finishes a piece, it enters a critical
  517.          section to grab the next available piece. This gives good load
  518.          balancing at the price of higher overhead.
  519.  
  520.          The interleave method (MMMMPPPP____SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE====IIIINNNNTTTTEEEERRRRLLLLEEEEAAAAVVVVEEEE) breaks the iterations
  521.          into pieces of the size specified by the CCCCHHHHUUUUNNNNKKKK option, and execution
  522.  
  523.  
  524.  
  525.                                                                         PPPPaaaaggggeeee 8888
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  533.  
  534.  
  535.  
  536.          of those pieces is interleaved among the processes.
  537.  
  538.          The fourth method is a variation of the guided self-scheduling
  539.          algorithm (MMMMPPPP____SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE====GGGGSSSSSSSS).  Here, the piece size is varied
  540.          depending on the number of iterations remaining. By parceling out
  541.          relatively large pieces to start with and relatively small pieces
  542.          toward the end, the system can achieve good load balancing while
  543.          reducing the number of entries into the critical section.
  544.  
  545.          In addition to these four methods, you can specify the scheduling
  546.          method at run time (MMMMPPPP____SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE====RRRRUUUUNNNNTTTTIIIIMMMMEEEE).  Here, the scheduling
  547.          routine examines values in your run-time environment and uses that
  548.          information to select one of the other four methods.
  549.  
  550.          If both the MMMMPPPP____SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE and CCCCHHHHUUUUNNNNKKKK clauses are omitted, SSSSIIIIMMMMPPPPLLLLEEEE
  551.          scheduling is assumed. If MMMMPPPP____SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE is set to IIIINNNNTTTTEEEERRRRLLLLEEEEAAAAVVVVEEEE or
  552.          DDDDYYYYNNNNAAAAMMMMIIIICCCC and the CCCCHHHHUUUUNNNNKKKK clause are omitted, CCCCHHHHUUUUNNNNKKKK====1111 is assumed. If
  553.          MMMMPPPP____SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE is set to one of the other values, CCCCHHHHUUUUNNNNKKKK is ignored. If
  554.          the MMMMPPPP____SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE clause is omitted, but CCCCHHHHUUUUNNNNKKKK is set, then
  555.          MMMMPPPP____SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE====DDDDYYYYNNNNAAAAMMMMIIIICCCC is assumed.
  556.  
  557.  
  558.      CCCC$$$$&&&&
  559.  
  560.      Occasionally, the clauses in the CCCC$$$$DDDDOOOOAAAACCCCRRRROOOOSSSSSSSS directive are longer than one
  561.      line. Use the CCCC$$$$&&&& directive to continue the directive onto multiple
  562.      lines.
  563.  
  564.      For example:
  565.  
  566.      C$DOACROSS share(ALPHA, BETA, GAMMA, DELTA,
  567.      C$&  EPSILON, OMEGA), LASTLOCAL(I, J, K, L, M, N),
  568.      C$&  LOCAL(XXX1, XXX2, XXX3, XXX4, XXX5, XXX6, XXX7,
  569.      C$&  XXX8, XXX9)
  570.  
  571.  
  572.      CCCC$$$$
  573.  
  574.      The CCCC$$$$ directive is considered a comment line except when
  575.      multiprocessing. A line beginning with C$ is treated as a conditionally
  576.      compiled Fortran statement. The rest of the line contains a standard
  577.      Fortran statement. The statement is compiled only if multiprocessing is
  578.      turned on. In this case, the C and $ are treated as if they are blanks.
  579.      They can be used to insert debugging statements, or an experienced user
  580.      can use them to insert arbitrary code into the multiprocessed version.
  581.  
  582.  
  583.      CCCC$$$$MMMMPPPP____SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE
  584.  
  585.      The CCCC$$$$MMMMPPPP____SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE====mmmmooooddddeeee directive acts as an implicit MMMMPPPP____SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE clause
  586.      for all CCCC$$$$DDDDOOOOAAAACCCCRRRROOOOSSSSSSSS directives in scope. mode is any of the modes listed
  587.      under CCCCHHHHUUUUNNNNKKKK and MMMMPPPP____SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE....  A CCCC$$$$DDDDOOOOAAAACCCCRRRROOOOSSSSSSSS directive that does not have
  588.  
  589.  
  590.  
  591.                                                                         PPPPaaaaggggeeee 9999
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  599.  
  600.  
  601.  
  602.      an explicit MMMMPPPP____SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE clause is given the value specified in the last
  603.      directive prior to the look, rather than the normal default. If the
  604.      CCCC$$$$DDDDOOOOAAAACCCCRRRROOOOSSSSSSSS does have an explicit clause, then the explicit value is used.
  605.  
  606.  
  607.      CCCC$$$$CCCCHHHHUUUUNNNNKKKK
  608.  
  609.      The CCCC$$$$CCCCHHHHUUUUNNNNKKKK====iiiinnnntttteeeeggggeeeerrrr____eeeexxxxpppprrrreeeessssssssiiiioooonnnn directive affects the CCCCHHHHUUUUNNNNKKKK clause of a
  610.      CCCC$$$$DDDDOOOOAAAACCCCRRRROOOOSSSSSSSS in the same way that the CCCC$$$$MMMMPPPP____SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE directive affects the
  611.      MMMMPPPP____SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE clause for all CCCC$$$$DDDDOOOOAAAACCCCRRRROOOOSSSSSSSS directives in scope. Both
  612.      directives are in effect from the place they occur in the source until
  613.      another corresponding directive is encountered or the end of the
  614.      procedure is reached.
  615.  
  616.  
  617.  
  618.      CCCC$$$$CCCCOOOOPPPPYYYYIIIINNNN
  619.  
  620.      It is occasionally desirable to be able to copy values from the master
  621.      thread's version of the COMMON block into the slave thread's version.
  622.      The special directive CCCC$$$$CCCCOOOOPPPPYYYYIIIINNNN allows this. It has the form
  623.  
  624.      C$COPYIN item [, item -]
  625.  
  626.      Each item must be a member of a local COMMON block. It can be a variable,
  627.      an array, an individual element of an array, or the entire COMMON block.
  628.  
  629.      Note:  The CCCC$$$$CCCCOOOOPPPPYYYYIIIINNNN directive cannot be executed from inside a parallel
  630.      region.
  631.  
  632.  
  633.      OOOOppppeeeennnnMMMMPPPP SSSSuuuuppppppppoooorrrrtttt
  634.  
  635.      The -_m_p flag enables the processing of the parallel (MP) directives,
  636.      including the original SGI/PCF directives (described below) as well as
  637.      the OpenMP directives.  To disable one or the other set use
  638.      -_M_P:_o_l_d__m_p=_O_F_F or -_M_P:_o_p_e_n__m_p=_O_F_F.  See the -_M_P option control group.
  639.      For more information about OpenMP support in MIPSpro Fortran 77, please
  640.      refer to the _M_I_P_S_p_r_o _F_o_r_t_r_a_n _7_7 _P_r_o_g_r_a_m_m_e_r'_s _G_u_i_d_e.  For more information
  641.      about OpenMP support in MIPSpro Fortran 90, please refer to the _M_I_P_S_P_r_o _7
  642.      _F_o_r_t_r_a_n _9_0 _C_o_m_m_a_n_d_s _a_n_d _D_i_r_e_c_t_i_v_e_s _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l.  For general
  643.      information about OpenMP please refer to the following web page:
  644.  
  645.                   http://www.openmp.org/
  646.  
  647.  
  648.  
  649.  
  650.      PPPPCCCCFFFF DDDDiiiirrrreeeeccccttttiiiivvvveeeessss
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.                                                                        PPPPaaaaggggeeee 11110000
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  665.  
  666.  
  667.  
  668.      In addition to the simple loop-level parallelism offered by CCCC$$$$DDDDOOOOAAAACCCCRRRROOOOSSSSSSSS
  669.      and the other directives described above, the compiler supports a more
  670.      general model of parallelism. This model is based on the work done by the
  671.      Parallel Computing Forum (PCF), which itself formed the basis for the
  672.      proposed ANSI-X3H5 standard. The compiler supports this model through
  673.      compiler directives, rather than extensions to the source language.  For
  674.      more information about PCF, please refer to Chapter 5 of the MIPSpro
  675.      Fortran 77 Programmer's Guide.
  676.  
  677.      The directives can be used in Fortran 77 programs when compiled with the
  678.      ----mmmmpppp option.
  679.  
  680.      CCCC$$$$PPPPAAAARRRR BBBBAAAARRRRRRRRIIIIEEEERRRR
  681.              Ensures that each process waits until all processes reach the
  682.              barrier before proceeding.
  683.  
  684.      CCCC$$$$PPPPAAAARRRR [[[[EEEENNNNDDDD]]]] CCCCRRRRIIIITTTTIIIICCCCAAAALLLL SSSSEEEECCCCTTTTIIIIOOOONNNN
  685.              Ensures that the enclosed block of code is executed by only one
  686.              process at a time by using a lock variable.
  687.  
  688.      CCCC$$$$PPPPAAAARRRR [[[[EEEENNNNDDDD]]]] PPPPAAAARRRRAAAALLLLLLLLEEEELLLL
  689.              Encloses a parallel region, which includes work-sharing
  690.              constructs and critical sections.
  691.  
  692.      CCCC$$$$PPPPAAAARRRR PPPPAAAARRRRAAAALLLLLLLLEEEELLLL DDDDOOOO
  693.              Precedes a single DO loop for which separate iterations are
  694.              executed by different processes. This directive is equivalent to
  695.              the CCCC$$$$DDDDOOOOAAAACCCCRRRROOOOSSSSSSSS directive.
  696.  
  697.      CCCC$$$$PPPPAAAARRRR [[[[EEEENNNNDDDD]]]] PPPPDDDDOOOO
  698.              Separate iterations of the enclosed loop are executed by
  699.              different processes. This directive must be inside a parallel
  700.              region.
  701.  
  702.      CCCC$$$$PPPPAAAARRRR [[[[EEEENNNNDDDD]]]] PPPPSSSSEEEECCCCTTTTIIIIOOOONNNN[[[[SSSS]]]]
  703.              Parcels out each block of code in turn to a process.
  704.  
  705.      CCCC$$$$PPPPAAAARRRR SSSSEEEECCCCTTTTIIIIOOOONNNN
  706.              Signifies a starting line for an individual section within a
  707.              parallel section.
  708.  
  709.      CCCC$$$$PPPPAAAARRRR [[[[EEEENNNNDDDD]]]] SSSSIIIINNNNGGGGLLLLEEEE PPPPRRRROOOOCCCCEEEESSSSSSSS
  710.              Ensures that the enclosed block of code is executed by exactly
  711.              one process.
  712.  
  713.      CCCC$$$$PPPPAAAARRRR &&&& Continues a PCF directive onto multiple lines.
  714.  
  715.  
  716.      PPPPaaaarrrraaaalllllllleeeellll RRRReeeeggggiiiioooonnnn
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.                                                                        PPPPaaaaggggeeee 11111111
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  731.  
  732.  
  733.  
  734.      A parallel region encloses any number of PCF constructs.  It signifies
  735.      the boundary within which slave threads execute. A user program can
  736.      contain any number of parallel regions. The syntax of the parallel region
  737.      is:
  738.  
  739.      C$PAR PARALLEL [clause [[,] clause]...]
  740.  
  741.                 code
  742.  
  743.      C$PAR END PARALLEL
  744.  
  745.      where valid clauses are:
  746.  
  747.      [IF ( logical_expression )]
  748.  
  749.      [{LOCAL | PRIVATE}(item [,item ...])]
  750.  
  751.      [{SHARE | SHARED}(item [,item ...])]
  752.  
  753.      The IIIIFFFF,,,, LLLLOOOOCCCCAAAALLLL,,,, and SSSSHHHHAAAARRRREEEEDDDD clauses have the same meaning as in the
  754.      CCCC$$$$DDDDOOOOAAAACCCCRRRROOOOSSSSSSSS directive.
  755.  
  756.      The preferred form of the directive has no commas between the clauses.
  757.      The SSSSHHHHAAAARRRREEEEDDDD clause is preferred over SSSSHHHHAAAARRRREEEE and LLLLOOOOCCCCAAAALLLL is preferred over
  758.      PPPPRRRRIIIIVVVVAAAATTTTEEEE....
  759.  
  760.  
  761.      PPPPCCCCFFFF CCCCoooonnnnssssttttrrrruuuuccccttttssss
  762.  
  763.      The three types of PCF constructs are work-sharing constructs, critical
  764.      sections, and barriers. All master and slave threads synchronize at the
  765.      bottom of a work-sharing construct. None of the threads continue past the
  766.      end of the construct until they all have completed execution within that
  767.      construct.
  768.  
  769.      The four work-sharing constructs are:  _p_a_r_a_l_l_e_l _D_O, _P_D_O, _s_e_c_t_i_o_n_s and
  770.      _s_i_n_g_l_e _p_r_o_c_e_s_s.
  771.  
  772.      If specified, these constructs (except for the parallel DO construct)
  773.      must appear inside of a parallel region.  Specifying a parallel DO
  774.      construct inside of a parallel region produces a syntax error.
  775.  
  776.      The critical section construct protects a block of code with a lock so
  777.      that it is executed by only one thread at a time. Threads do not
  778.      synchronize at the bottom of a critical section.
  779.  
  780.      The barrier construct ensures that each process that is executing waits
  781.      until all others reach the barrier before proceeding.
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.                                                                        PPPPaaaaggggeeee 11112222
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  797.  
  798.  
  799.  
  800.      PPPPaaaarrrraaaalllllllleeeellll DDDDOOOO
  801.  
  802.      The parallel DO construct is the same as the CCCC$$$$DDDDOOOOAAAACCCCRRRROOOOSSSSSSSS directive and
  803.      conceptually the same as a parallel region containing exactly one PDO
  804.      construct and no other code. Each thread inside the enclosing parallel
  805.      region executes separate iterations of the loop within the parallel DO
  806.      construct. The syntax of the parallel DO construct is
  807.  
  808.      C$PAR PARALLEL DO [clause [[,] clause]...]
  809.  
  810.      where clause is defined as the same as for CCCC$$$$DDDDOOOOAAAACCCCRRRROOOOSSSSSSSS....
  811.  
  812.      For the CCCC$$$$PPPPAAAARRRR PPPPAAAARRRRAAAALLLLLLLLEEEELLLL DDDDOOOO directive, MMMMPPPP____SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE==== is optional; you can
  813.      just specify mode.
  814.  
  815.  
  816.      PPPPDDDDOOOO
  817.  
  818.      Each thread inside the enclosing parallel region executes a separate
  819.      iteration of the loop within the PDO construct. The syntax of the PDO
  820.      construct, which can only be specified within a parallel region, is:
  821.  
  822.      C$PAR PDO [clause [[,] clause]...]
  823.  
  824.              code
  825.  
  826.      [C$PAR END PDO [NOWAIT]]
  827.  
  828.      where valid values for clause are
  829.  
  830.      [{LOCAL | PRIVATE} (item[,item ...])]
  831.  
  832.      [{LASTLOCAL | LAST LOCAL} (item[,item ...])]
  833.  
  834.      [(ORDERED)]
  835.  
  836.      [ sched ]
  837.  
  838.      [ chunk ]
  839.  
  840.      LLLLOOOOCCCCAAAALLLL,,,, LLLLAAAASSSSTTTTLLLLOOOOCCCCAAAALLLL,,,, sssscccchhhheeeedddd,,,, and cccchhhhuuuunnnnkkkk have the same meaning as in the
  841.      CCCC$$$$DDDDOOOOAAAACCCCRRRROOOOSSSSSSSS directive. Note in particular that it is legal to declare a
  842.      data item as LLLLOOOOCCCCAAAALLLL in a PPPPDDDDOOOO even if it was declared as SSSSHHHHAAAARRRREEEEDDDD in the
  843.      enclosing parallel region. The ((((OOOORRRRDDDDEEEERRRREEEEDDDD)))) clause is equivalent to a sched
  844.      clause of DDDDYYYYNNNNAAAAMMMMIIIICCCC and a chunk clause of 1. The parenthesis are required.
  845.      LLLLAAAASSSSTTTTLLLLOOOOCCCCAAAALLLL is preferred over LLLLAAAASSSSTTTT LLLLOOOOCCCCAAAALLLL and LLLLOOOOCCCCAAAALLLL is preferred over
  846.      PPPPRRRRIIIIVVVVAAAATTTTEEEE....
  847.  
  848.      The EEEENNNNDDDD PPPPDDDDOOOO directive is optional. If specified, this directive must
  849.      appear immediately after the end of the DO loop. The optional NNNNOOOOWWWWAAAAIIIITTTT
  850.      clause specifies that each process should proceed directly to the code
  851.      immediately following the directive. If you do not specify NNNNOOOOWWWWAAAAIIIITTTT,,,, the
  852.  
  853.  
  854.  
  855.                                                                        PPPPaaaaggggeeee 11113333
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  863.  
  864.  
  865.  
  866.      processes will wait until all have reached the directive before
  867.      proceeding.
  868.  
  869.  
  870.      PPPPaaaarrrraaaalllllllleeeellll SSSSeeeeccccttttiiiioooonnnnssss
  871.  
  872.      The parallel sections construct is a parallel version of the Fortran 90
  873.      SSSSEEEELLLLEEEECCCCTTTT statement. Each block of code is parceled out in turn to a
  874.      separate thread. The syntax of the parallel sections construct is
  875.  
  876.      C$PAR PSECTION[S] [clause [[,]clause ]...
  877.  
  878.         code
  879.  
  880.      [C$PAR SECTION
  881.  
  882.            code] ...
  883.  
  884.      C$PAR END PSECTION[S] [NOWAIT]
  885.  
  886.      where the only valid value for clause is
  887.  
  888.      [{LOCAL | PRIVATE} (item [,item]) ]
  889.  
  890.      LLLLOOOOCCCCAAAALLLL is preferred over PPPPRRRRIIIIVVVVAAAATTTTEEEE and has the same meaning as for the
  891.      CCCC$$$$DDDDOOOOAAAACCCCRRRROOOOSSSSSSSS directive. Note in particular that it is legal to declare a
  892.      data item as LLLLOOOOCCCCAAAALLLL in a parallel sections construct even if it was
  893.      declared as SSSSHHHHAAAARRRREEEEDDDD in the enclosing parallel region.
  894.  
  895.      The optional NNNNOOOOWWWWAAAAIIIITTTT clause specifies that each process should proceed
  896.      directly to the code immediately following the directive. If you do not
  897.      specify NNNNOOOOWWWWAAAAIIIITTTT,,,, the processes will wait until all have reached the EEEENNNNDDDD
  898.      PPPPSSSSEEEECCCCTTTTIIIIOOOONNNN directive before proceeding.
  899.  
  900.      Parallel sections must appear within a parallel region. They can contain
  901.      critical section constructs but cannot contain any of the following types
  902.      of constructs:  _P_D_O, _p_a_r_a_l_l_e_l _D_O, _C$_D_O_A_C_R_O_S_S or _s_i_n_g_l_e _p_r_o_c_e_s_s.
  903.  
  904.      The sections within a parallel sections construct are assigned to threads
  905.      one at a time, from the top down. There is no other implied ordering to
  906.      the operations within the sections. In particular, a later section cannot
  907.      depend on the results of an earlier section, unless some form of explicit
  908.      synchronization is used. If there is such explicit synchronization, you
  909.      must be sure that the lexical ordering of the blocks is a legal order of
  910.      execution.
  911.  
  912.  
  913.  
  914.      SSSSiiiinnnngggglllleeee PPPPrrrroooocccceeeessssssss
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.                                                                        PPPPaaaaggggeeee 11114444
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  929.  
  930.  
  931.  
  932.      The single process construct, which can only be specified within a
  933.      parallel region, ensures that a block of code is executed by exactly one
  934.      process. The syntax of the single process construct is
  935.  
  936.      C$PAR SINGLE PROCESS [clause [[,] clause]...]
  937.  
  938.          code
  939.  
  940.      C$PAR END SINGLE PROCESS [NOWAIT]
  941.  
  942.      where the only valid value for clause is
  943.  
  944.      [{LOCAL | PRIVATE} (item [,item]) ]
  945.  
  946.      LLLLOOOOCCCCAAAALLLL is preferred over PPPPRRRRIIIIVVVVAAAATTTTEEEE and has the same meaning as for the
  947.      CCCC$$$$DDDDOOOOAAAACCCCRRRROOOOSSSSSSSS directive. Note in particular that it is legal to declare a
  948.      data item as LLLLOOOOCCCCAAAALLLL in a single process construct even if it was declared
  949.      as SSSSHHHHAAAARRRREEEEDDDD in the enclosing parallel region.
  950.  
  951.      The optional NNNNOOOOWWWWAAAAIIIITTTT clause specifies that each process should proceed
  952.      directly to the code immediately following the directive. If you do not
  953.      specify NNNNOOOOWWWWAAAAIIIITTTT,,,, the processes will wait until all have reached the
  954.      directive before proceeding.  This construct is semantically equivalent
  955.      to a parallel sections construct with only one section. The single
  956.      process construct provides a more descriptive syntax.
  957.  
  958.  
  959.      CCCCrrrriiiittttiiiiccccaaaallll SSSSeeeeccccttttiiiioooonnnn
  960.  
  961.      The critical section construct restricts execution of a block of code so
  962.      that only one process can execute it at a time. Another process
  963.      attempting to gain entry to the critical section must wait until the
  964.      previous process has exited.
  965.  
  966.      The critical section construct can appear anywhere in a program,
  967.      including inside and outside a parallel region and within a C$ DOACROSS
  968.      loop. The syntax of the critical section construct is
  969.  
  970.      C$PAR CRITICAL SECTION [ ( lock_variable ) ]
  971.  
  972.          code
  973.  
  974.      C$PAR END CRITICAL SECTION
  975.  
  976.      The _l_o_c_k__v_a_r_i_a_b_l_e is an optional integer variable that must be
  977.      initialized to zero. The parenthesis are required. If you do not specify
  978.      _l_o_c_k__v_a_r_i_a_b_l_e, the compiler automatically supplies one. Multiple critical
  979.      section constructs inside the same parallel region are considered to be
  980.      independent of each other unless they use the same explicit
  981.      _l_o_c_k__v_a_r_i_a_b_l_e.
  982.  
  983.  
  984.  
  985.  
  986.  
  987.                                                                        PPPPaaaaggggeeee 11115555
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  995.  
  996.  
  997.  
  998.      BBBBaaaarrrrrrrriiiieeeerrrr CCCCoooonnnnssssttttrrrruuuuccccttttssss
  999.  
  1000.      A barrier construct ensures that each process waits until all processes
  1001.      reach the barrier before proceeding. The syntax of the barrier construct
  1002.      is
  1003.  
  1004.      CCCC$$$$PPPPAAAARRRR BBBBAAAARRRRRRRRIIIIEEEERRRR CCCC$$$$PPPPAAAARRRR &&&&
  1005.  
  1006.      Occasionally, the clauses in PCF directives are longer than one line. You
  1007.      can use the CCCC$$$$PPPPAAAARRRR &&&& directive to continue a directive onto multiple
  1008.      lines.
  1009.  
  1010.      For example:
  1011.  
  1012.      C$PAR PARALLEL local(i,j)
  1013.  
  1014.      C$PAR& shared(a,n,index_x,index_y,cur_max,
  1015.  
  1016.      C$PAR& big_max,bmax_x,bmax_y)
  1017.  
  1018.  
  1019.      RRRReeeessssttttrrrriiiiccccttttiiiioooonnnnssss
  1020.  
  1021.      The three work-sharing constructs, PPPPDDDDOOOO,,,, PPPPSSSSEEEECCCCTTTTIIIIOOOONNNN,,,, and SSSSIIIINNNNGGGGLLLLEEEE PPPPRRRROOOOCCCCEEEESSSSSSSS,,,,
  1022.      must be executed by all the threads executing in the parallel region (or
  1023.      none of the threads). The following is illegal:
  1024.  
  1025.      C$PAR PARALLEL
  1026.  
  1027.              if (mp_my_threadnum() .gt. 5) then
  1028.  
  1029.      C$PAR SINGLE PROCESS
  1030.  
  1031.                  many_processes = .true.
  1032.  
  1033.      C$PAR END SINGLE PROCESS
  1034.  
  1035.              endif
  1036.  
  1037.      This code will hang forever when run with enough processes. One or more
  1038.      process will be stuck at the CCCC$$$$PPPPAAAARRRR EEEENNNNDDDD SSSSIIIINNNNGGGGLLLLEEEE PPPPRRRROOOOCCCCEEEESSSSSSSS directive waiting
  1039.      for all the threads to arrive. Because some of the threads never took the
  1040.      appropriate branch, they will never encounter the construct. However, the
  1041.      following kind of simple looping is supported:
  1042.  
  1043.           code
  1044.  
  1045.      C$PAR PARALLEL local(i,j) shared(a)
  1046.  
  1047.              do i= 1,n
  1048.  
  1049.      C$PAR PDO
  1050.  
  1051.  
  1052.  
  1053.                                                                        PPPPaaaaggggeeee 11116666
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  1061.  
  1062.  
  1063.  
  1064.                do j = 2,n
  1065.  
  1066.           code
  1067.  
  1068.      The distinction here is that all of the threads encounter the work-
  1069.      sharing construct, they all complete it, and they all loop around and
  1070.      encounter it again.
  1071.  
  1072.      Note that this restriction does not apply to the critical section
  1073.      construct, which operates on one thread at a time without regard to any
  1074.      other threads.
  1075.  
  1076.      Parallel regions cannot be lexically nested inside of other parallel
  1077.      regions, nor can work-sharing constructs be nested. However, as an aid to
  1078.      writing library code, you can call an external routine that contains a
  1079.      parallel region even from within a parallel region.
  1080.  
  1081.      In this case, only the first region is actually run in parallel.
  1082.      Therefore, you can create a parallelized routine without accounting for
  1083.      whether it will be called from within an already parallelized routine.
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.      NNNNeeeewwww DDDDiiiirrrreeeeccccttttiiiivvvveeeessss ffffoooorrrr TTTTuuuunnnniiiinnnngggg oooonnnn OOOOrrrriiiiggggiiiinnnn2222000000000000
  1091.  
  1092.      The Origin2000 provides cache-coherent, shared memory in the hardware.
  1093.      Memory is physically distributed across processors. Consequently,
  1094.      references to locations in the remote memory of another processor take
  1095.      substantially longer (by a factor of two or more) to complete than
  1096.      references to locations in local memory. This can severely affect the
  1097.      performance of programs that suffer from a large number of cache misses.
  1098.  
  1099.      The programming support consists of extensions to the existing
  1100.      Multiprocessing Fortran directives (pragmas). The table below summarizes
  1101.      the new directives. Like the other Multiprocessing Fortran directives,
  1102.      these new directives are ignored except under multiprocessor ----mmmmpppp
  1103.      compilation.
  1104.  
  1105.      tab (/); c s l l l l .  Summary of New Directives
  1106.  
  1107.      Directive/Description
  1108.  
  1109.      c$distribute A (dist, dist, ...)/Data distribution c$dynamic
  1110.      A/Redistributable annotation c$distribute_reshape B(dist)/Data
  1111.      distribution with reshaping c$redistribute A(dist, dist)/Dynamic data
  1112.      redistribution c$doacross nest (i,j) /Nested doacross c$doacross affinity
  1113.      (i) = data (A(i))/Data-affinity scheduling c$doacross affinity (i) =
  1114.      thread (expr)/Thread-affinity scheduling c$page_place (addr, sz,
  1115.      thread)/Explicit placement of data
  1116.  
  1117.  
  1118.  
  1119.                                                                        PPPPaaaaggggeeee 11117777
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  1127.  
  1128.  
  1129.  
  1130.      DDDDaaaattttaaaa DDDDiiiissssttttrrrriiiibbbbuuuuttttiiiioooonnnn DDDDiiiirrrreeeeccccttttiiiivvvveeeessss
  1131.  
  1132.      The data distribution directives allow you to specify High Performance
  1133.      Fortran-like distributions for array data structures. For irregular data
  1134.      structures, directives are provided to explicitly place data directly on
  1135.      a specific processor.
  1136.  
  1137.      The cccc$$$$ddddiiiissssttttrrrriiiibbbbuuuutttteeee,,,, cccc$$$$ddddyyyynnnnaaaammmmiiiicccc,,,, and ddddiiiissssttttrrrriiiibbbbuuuutttteeee____rrrreeeesssshhhhaaaappppeeee directives are
  1138.      declarations that must be specified in the declaration part of the
  1139.      program, along with the array declaration. The cccc$$$$rrrreeeeddddiiiissssttttrrrriiiibbbbuuuutttteeee directive
  1140.      is an executable statement and can appear in any executable portion of
  1141.      the program.
  1142.  
  1143.      You can specify a data distribution directive for any local, global, or
  1144.      common-block array. Each dimension of a multi-dimensional array can be
  1145.      independently distributed.
  1146.  
  1147.      The possible distribution types for an array dimension are BBBBLLLLOOOOCCCCKKKK,,,, CCCCYYYYCCCCLLLLIIIICCCC
  1148.      ( expr ) and **** (asterisk not distributed). (A CCCCYYYYCCCCLLLLIIIICCCC distribution with a
  1149.      chunk size that is either greater than 1 or is determined at runtime is
  1150.      sometimes also called BLOCK-CYCLIC ).
  1151.  
  1152.      A BBBBLLLLOOOOCCCCKKKK distribution partitions the elements of the dimension of size _N
  1153.      into _P blocks (one per processor), with each block of size _B =
  1154.      _c_e_i_l_i_n_g(_N/_P) .
  1155.  
  1156.      A CCCCYYYYCCCCLLLLIIIICCCC((((kkkk)))) distribution partitions the elements of the dimension into
  1157.      pieces of size _k each and distributes them sequentially across the
  1158.      processors.
  1159.  
  1160.  
  1161.      A distributed array is distributed across all the processors being used
  1162.      in that particular execution of the program, as determined by the
  1163.      environment variable MMMMPPPP____SSSSEEEETTTT____NNNNUUUUMMMMTTTTHHHHRRRREEEEAAAADDDDSSSS.... If a distributed array is
  1164.      distributed in more than one dimension, then by default the processors
  1165.      are apportioned as equally as possible across each distributed dimension.
  1166.      For instance, if an array has two distributed dimensions, then an
  1167.      execution with 16 processors will assign 4 processors to each dimension
  1168.      (4 x 4=16), whereas an execution with 8 processors will assign 4
  1169.      processors to the first dimension and 2 processors to the second
  1170.      dimension. You can override this default and explicitly control the
  1171.      number of processors in each dimension using the OOOONNNNTTTTOOOO clause with a data
  1172.      distribution directive.
  1173.  
  1174.  
  1175.  
  1176.      NNNNeeeesssstttteeeedddd DDDDooooaaaaccccrrrroooossssssss DDDDiiiirrrreeeeccccttttiiiivvvveeee
  1177.  
  1178.      The nested doacross directive allows you to exploit nested concurrency in
  1179.      a limited manner. Although true nested parallelism is not supported, you
  1180.      can exploit parallelism across iterations of a perfectly nested loop-
  1181.      nest. For example:
  1182.  
  1183.  
  1184.  
  1185.                                                                        PPPPaaaaggggeeee 11118888
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  1193.  
  1194.  
  1195.  
  1196.      c$doacross nest(i, j)
  1197.  
  1198.      do i =
  1199.  
  1200.         do j =
  1201.  
  1202.             code
  1203.  
  1204.         enddo
  1205.  
  1206.      enddo
  1207.  
  1208.      This directive specifies that the entire set of iterations across the (i,
  1209.      j) loops can be executed concurrently. The restriction is that the do-i
  1210.      and do-j loops must be perfectly nested, that is, no code is allowed
  1211.      between either the do-i and do-j statements or the enddo-i and enddo-j
  1212.      statements. You can also supply the nest clause with the PCF directive
  1213.      ppppddddoooo....
  1214.  
  1215.      The existing clauses such as _l_o_c_a_l and _s_h_a_r_e_d behave as before. You can
  1216.      combine a nested doacross with an affinity clause (as shown below), or
  1217.      with a schedtype of simple or interleaved (dynamic and gss are not
  1218.      currently supported). The default is simple scheduling, except when
  1219.      accessing reshaped arrays (see Affinity Scheduling).
  1220.  
  1221.  
  1222.      AAAAffffffffiiiinnnniiiittttyyyy SSSScccchhhheeeedddduuuulllliiiinnnngggg
  1223.  
  1224.      The goal of affinity scheduling is to control the mapping of iterations
  1225.      of a parallel loop for execution onto the underlying threads. Specify
  1226.      affinity scheduling with an additional clause to a cccc$$$$ddddooooaaaaccccrrrroooossssssss directive.
  1227.      An aaaaffffffffiiiinnnniiiittttyyyy clause, if supplied, overrides the SSSSCCCCHHHHEEEEDDDDTTTTYYYYPPPPEEEE clause.
  1228.  
  1229.  
  1230.  
  1231.      DDDDaaaattttaaaa AAAAffffffffiiiinnnniiiittttyyyy
  1232.  
  1233.      The following code shows an example of data affinity:
  1234.  
  1235.      c$distribute A(block)
  1236.  
  1237.      c$doacross affinity(i) = data(A(a*i+b))
  1238.  
  1239.      do i = 1, N
  1240.         ...
  1241.  
  1242.      enddo
  1243.  
  1244.      The _a and _b must be literal integer constants with a greater than zero.
  1245.      The effect of this clause is to distribute the iterations of the parallel
  1246.      loop to match the data distribution specified for the array _A, such that
  1247.      iteration _i is executed on the processor that owns element _A(_a*_i+_b) based
  1248.  
  1249.  
  1250.  
  1251.                                                                        PPPPaaaaggggeeee 11119999
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  1259.  
  1260.  
  1261.  
  1262.      on the distribution for _A.
  1263.  
  1264.      In case of a multi-dimensional array, affinity is provided for the
  1265.      dimension that contains the loop-index variable. The loop-index variable
  1266.      cannot appear in more than one dimension in an affinity directive. For
  1267.      example:
  1268.  
  1269.      c$distribute A (block, cyclic(1))
  1270.  
  1271.      c$doacross affinity (i) = data (A(i+3, j))
  1272.  
  1273.      do i
  1274.  
  1275.         ...
  1276.  
  1277.      enddo
  1278.  
  1279.      In this example, the loop is scheduled based on the block-distribution of
  1280.      the first dimension. The affinity clause is also available with the PCF
  1281.      ppppddddoooo directive.
  1282.  
  1283.      The default sssscccchhhheeeeddddttttyyyyppppeeee for parallel loops is SSSSIIIIMMMMPPPPLLLLEEEE....  However, under ----OOOO3333
  1284.      compilation, level loops that reference reshaped arrays default to
  1285.      affinity scheduling for the most frequently accessed reshaped array in
  1286.      the loop (chosen heuristically by the compiler). To obtain SSSSIIIIMMMMPPPPLLLLEEEE
  1287.      scheduling even at ----OOOO3333,,,, you can explicitly specify the schedtype on the
  1288.      parallel loop.
  1289.  
  1290.      Data affinity for loops with non-unit stride can sometimes result in
  1291.      non-linear affinity expressions. In such situations the compiler issues a
  1292.      warning, ignores the affinity clause, and defaults to simple scheduling.
  1293.  
  1294.  
  1295.  
  1296.      DDDDaaaattttaaaa AAAAffffffffiiiinnnniiiittttyyyy ffffoooorrrr RRRReeeeddddiiiissssttttrrrriiiibbbbuuuutttteeeedddd AAAArrrrrrrraaaayyyyssss
  1297.  
  1298.      By default, the compiler assumes that a distributed array is not
  1299.      dynamically redistributed, and directly schedules a parallel loop for the
  1300.      specified data affinity. In contrast, a redistributed array can have
  1301.      multiple possible distributions, and data affinity for a redistributed
  1302.      array must be implemented in the run-time system based on the particular
  1303.      distribution.
  1304.  
  1305.      However, the compiler does not know whether or not an array is
  1306.      redistributed, since the array may be redistributed in another function
  1307.      (possibly even in another file). Therefore, you must explicitly specify
  1308.      the cccc$$$$ddddyyyynnnnaaaammmmiiiicccc declaration for redistributed arrays. You must supply this
  1309.      directive only in those functions that contain a cccc$$$$ddddooooaaaaccccrrrroooossssssss loop with
  1310.      data affinity for that array.  This informs the compiler that the array
  1311.      can be dynamically redistributed. Data affinity for such arrays is
  1312.      implemented through a run-time lookup.
  1313.  
  1314.  
  1315.  
  1316.  
  1317.                                                                        PPPPaaaaggggeeee 22220000
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  1325.  
  1326.  
  1327.  
  1328.      Implementing data affinity through a run-time lookup incurs some extra
  1329.      overhead compared to a direct compile-time implementation. You can avoid
  1330.      this overhead in situations where a subroutine contains data affinity for
  1331.      a redistributed array, and you know the distribution of the array for the
  1332.      entire duration of that subroutine. In this situation, you can supply the
  1333.      cccc$$$$ddddiiiissssttttrrrriiiibbbbuuuutttteeee directive with the particular distribution, and omit the
  1334.      cccc$$$$ddddyyyynnnnaaaammmmiiiicccc directive.
  1335.  
  1336.      By default, the compiler assumes that a distributed array is not
  1337.      redistributed at runtime. As a result, the distribution is known at
  1338.      compile time, and data affinity for the array can be implemented directly
  1339.      by the compiler. In contrast, since a redistributed array can have
  1340.      multiple possible distributions at runtime, data affinity for a
  1341.      redistributed array is implemented in the run-time system based on the
  1342.      distribution at runtime, incurring extra run-time overhead.
  1343.  
  1344.      If an array is redistributed in the program, then you can explicitly
  1345.      specify a cccc$$$$ddddyyyynnnnaaaammmmiiiicccc directive for that array. The only effect of the
  1346.      cccc$$$$ddddyyyynnnnaaaammmmiiiicccc directive is to implement data affinity for that array at
  1347.      runtime rather than at compile time. If you know an array has a specified
  1348.      distribution throughout the duration of a subroutine, then you do not
  1349.      have to supply the cccc$$$$ddddyyyynnnnaaaammmmiiiicccc directive. The result is more efficient
  1350.      compile time affinity scheduling.
  1351.  
  1352.      Since reshaped arrays cannot be dynamically redistributed, this is an
  1353.      issue only for regular data distribution.
  1354.  
  1355.  
  1356.  
  1357.      DDDDaaaattttaaaa AAAAffffffffiiiinnnniiiittttyyyy ffffoooorrrr aaaa FFFFoooorrrrmmmmaaaallll PPPPaaaarrrraaaammmmeeeetttteeeerrrr
  1358.  
  1359.      You can supply a cccc$$$$ddddiiiissssttttrrrriiiibbbbuuuutttteeee directive on a formal parameter, thereby
  1360.      specifying the distribution on the incoming actual parameter. If
  1361.      different calls to the subroutine have parameters with different
  1362.      distributions, then you can omit the c$distribute directive on the formal
  1363.      parameter; data affinity loops in that subroutine are automatically
  1364.      implemented through a run-time lookup of the distribution. (This is
  1365.      permissible only for regular data distribution. For reshaped array
  1366.      parameters, the distribution must be fully specified on the formal
  1367.      parameter.)
  1368.  
  1369.  
  1370.      TTTThhhhrrrreeeeaaaadddd AAAAffffffffiiiinnnniiiittttyyyy
  1371.  
  1372.      Similar to data affinity, you can specify thread affinity as an
  1373.      additional clause on a cccc$$$$ddddooooaaaaccccrrrroooossssssss directive. The syntax for thread
  1374.      affinity is as follows:
  1375.  
  1376.      c$doacross affinity (i) = thread(expr)
  1377.  
  1378.      The effect of this directive is to execute iteration _i on the thread
  1379.      number given by the user-supplied expression (modulo the number of
  1380.  
  1381.  
  1382.  
  1383.                                                                        PPPPaaaaggggeeee 22221111
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  1391.  
  1392.  
  1393.  
  1394.      threads).
  1395.  
  1396.  
  1397.  
  1398.      SSSSppppeeeecccciiiiffffyyyyiiiinnnngggg PPPPrrrroooocccceeeessssssssoooorrrr TTTTooooppppoooollllooooggggyyyy WWWWiiiitttthhhh tttthhhheeee OOOONNNNTTTTOOOO
  1399.  
  1400.      This directive allows you to specify the processor topology when two (or
  1401.      more) dimensions of processors are required. For instance, if an array is
  1402.      distributed in two dimensions, then you can use the OOOONNNNTTTTOOOO clause to
  1403.      specify how to partition the processors across the distributed
  1404.      dimensions. Or, in a nested doacross with two or more nested loops, you
  1405.      can use the OOOONNNNTTTTOOOO clause to specify the partitioning of processors across
  1406.      the multiple parallel loops.
  1407.  
  1408.      For example:
  1409.  
  1410.      c Assign processor in the ratio 1:2 to the two dimension
  1411.  
  1412.      real*8 A (100, 200)
  1413.  
  1414.      c$distribute A (block, block) onto (1, 2)
  1415.  
  1416.      c Use 2 processors in the do-i loop, and the remaining in the do-j loop
  1417.  
  1418.      c$doacross nest (i, j) onto (2, *)
  1419.  
  1420.      do i =
  1421.  
  1422.        do j =
  1423.  
  1424.           code
  1425.  
  1426.        enddo
  1427.  
  1428.      enddo
  1429.  
  1430.  
  1431.      TTTTyyyyppppeeeessss ooooffff DDDDaaaattttaaaa DDDDiiiissssttttrrrriiiibbbbuuuuttttiiiioooonnnn
  1432.  
  1433.      There are two types of data distribution: rrrreeeegggguuuullllaaaarrrr and rrrreeeesssshhhhaaaappppeeeedddd....  The
  1434.      following sections describe each of these distributions.
  1435.  
  1436.  
  1437.      RRRReeeegggguuuullllaaaarrrr DDDDaaaattttaaaa DDDDiiiissssttttrrrriiiibbbbuuuuttttiiiioooonnnn
  1438.  
  1439.      The regular data distribution directives try to achieve the desired
  1440.      distribution solely by influencing the mapping of virtual addresses to
  1441.      physical pages without affecting the layout of the data structure. Since
  1442.      the granularity of data allocation is a physical page (at least 16
  1443.      Kbytes), the achieved distribution is limited by the underlying page-
  1444.      granularity. However, the advantages are that regular data distribution
  1445.      directives can be added to an existing program without any restrictions,
  1446.  
  1447.  
  1448.  
  1449.                                                                        PPPPaaaaggggeeee 22222222
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  1457.  
  1458.  
  1459.  
  1460.      and can be used for affinity scheduling.
  1461.  
  1462.      Distributed arrays can be dynamically redistributed with the following
  1463.      redistribute statement:
  1464.  
  1465.      c$redistribute A (block, cyclic(k))
  1466.  
  1467.      The cccc$$$$rrrreeeeddddiiiissssttttrrrriiiibbbbuuuutttteeee is an executable statement that changes the
  1468.      distribution "permanently" (or until another redistribute statement). It
  1469.      also affects subsequent affinity scheduling.
  1470.  
  1471.      The cccc$$$$ddddyyyynnnnaaaammmmiiiicccc directive specifies that the named array is redistributed
  1472.      in the program, and is useful in controlling affinity scheduling for
  1473.      dynamically redistributed arrays.
  1474.  
  1475.  
  1476.  
  1477.      DDDDaaaattttaaaa DDDDiiiissssttttrrrriiiibbbbuuuuttttiiiioooonnnn WWWWiiiitttthhhh RRRReeeesssshhhhaaaappppiiiinnnngggg
  1478.  
  1479.      Similar to regular data distribution, the reshape directive specifies the
  1480.      desired distribution of an array. In addition, however, the reshape
  1481.      directive declares that the program makes no assumptions about the
  1482.      storage layout of that array. The compiler performs aggressive
  1483.      optimizations for reshaped arrays that violate standard Fortran77 layout
  1484.      assumptions but guarantee the desired data distribution for that array.
  1485.  
  1486.      The reshape directive accepts the same distributions as the regular data
  1487.      distribution directive, but uses a different keyword, as shown below:
  1488.  
  1489.      c$distribute_reshape (block, cyclic(1))
  1490.  
  1491.  
  1492.      RRRReeeessssttttrrrriiiiccccttttiiiioooonnnnssss oooonnnn RRRReeeesssshhhhaaaappppeeeedddd AAAArrrrrrrraaaayyyyssss
  1493.  
  1494.      Since the distribute_reshape directive specifies that the program does
  1495.      not depend on the storage layout of the reshaped array, restrictions on
  1496.      the arrays that can be reshaped include the following:
  1497.  
  1498.          The distribution of a reshaped array cannot be changed
  1499.  
  1500.          Initialized data cannot be reshaped.
  1501.  
  1502.          Arrays that are explicitly allocated through alloca/malloc and
  1503.          accessed through pointers cannot be reshaped.
  1504.  
  1505.          An array that is equivalenced to another array cannot be reshaped.
  1506.  
  1507.          I/O for a reshaped array cannot be mixed with namelist I/O or a
  1508.          function call in the same I/O statement.
  1509.  
  1510.          A COMMON block containing a reshaped array cannot be linked ----XXXXllllooooccccaaaallll
  1511.          Caution:  This user error is not caught by the compiler/linker.
  1512.  
  1513.  
  1514.  
  1515.                                                                        PPPPaaaaggggeeee 22223333
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  1523.  
  1524.  
  1525.  
  1526.      If a reshaped array is passed as an actual parameter to a subroutine, two
  1527.      possible scenarios exist:
  1528.  
  1529.          The array is passed in its entirety ( _c_a_l_l _f_u_n_c(_A) passes the entire
  1530.          array _A, whereas _c_a_l_l _f_u_n_c(_A(_i,_j)) passes a portion of _A ). The
  1531.          compiler automatically clones a copy of the called subroutine and
  1532.          compiles it for the incoming distribution. The actual and formal
  1533.          parameters must match in the number of dimensions, and the size of
  1534.          each dimension. You can restrict a subroutine to accept a particular
  1535.          reshaped distribution on a parameter by specifying a
  1536.          distribute_reshape directive on the formal parameter within the
  1537.          subroutine. All calls to this subroutine with a mismatched
  1538.          distribution will lead to compile- or link-time errors.
  1539.  
  1540.          A portion of the array can be passed as a parameter, but the callee
  1541.          must access only a single processor's portion. If the callee exceeds
  1542.          a single processor's portion, then the results are undefined. You can
  1543.          use intrinsics to access details about the array distribution.
  1544.  
  1545.  
  1546.      EEEErrrrrrrroooorrrr----DDDDeeeetttteeeeccccttttiiiioooonnnn SSSSuuuuppppppppoooorrrrtttt
  1547.  
  1548.      Most errors in accessing reshaped arrays are caught either at compile
  1549.      time or at link time. These include:
  1550.  
  1551.          Inconsistencies in reshaped arrays across COMMON blocks (including
  1552.          across files)
  1553.  
  1554.          Declaring a reshaped array EQUIVALENCED to another array
  1555.  
  1556.          Inconsistencies in reshaped distributions on actual and formal
  1557.          parameters
  1558.  
  1559.          Other errors such as disallowed I/O statements involving reshaped
  1560.          arrays, reshaping initialized data, or reshaping dynamically
  1561.          allocated data
  1562.  
  1563.      Errors such as matching the declared size of an array dimension typically
  1564.      are caught only at runtime. The compiler option, ----MMMMPPPP::::cccchhhheeeecccckkkk____rrrreeeesssshhhhaaaappppeeee====oooonnnn,,,,
  1565.      generates code to perform these tests at runtime. These run-time checks
  1566.      are not generated by default, since they incur overhead, but are useful
  1567.      during debugging. The runtime checks include:
  1568.  
  1569.          Inconsistencies in array-bound declarations on each actual and formal
  1570.          parameter
  1571.  
  1572.          Inconsistencies in declared bounds of a formal parameter that
  1573.          corresponds to a portion of a reshaped actual parameter.
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.                                                                        PPPPaaaaggggeeee 22224444
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  1589.  
  1590.  
  1591.  
  1592.      QQQQuuuueeeerrrryyyy IIIInnnnttttrrrriiiinnnnssssiiiiccccssss ffffoooorrrr DDDDiiiissssttttrrrriiiibbbbuuuutttteeeedddd AAAArrrrrrrraaaayyyyssss
  1593.  
  1594.      You can use the following set of intrinsics to obtain information about
  1595.      an individual dimension of a distributed array. Fortran array dimensions
  1596.      are numbered starting at 1. All routines work with 64-bit integers as
  1597.      shown below, and return -1 in case of an error (except
  1598.      ddddssssmmmm____tttthhhhiiiissss____ssssttttaaaarrrrttttiiiinnnnggggiiiinnnnddddeeeexxxx where -1 may be a legal return value).
  1599.  
  1600.      iiii8888 ==== ddddssssmmmm____nnnnuuuummmmtttthhhhrrrreeeeaaaaddddssss ((((AAAA,,,, jjjj8888))))
  1601.  
  1602.      Called with a distributed array and a dimension number. Returns the
  1603.      number of threads in that dimension.
  1604.  
  1605.      iiii8888 ==== ddddssssmmmm____cccchhhhuuuunnnnkkkkssssiiiizzzzeeee ((((AAAA,,,, jjjj8888))))
  1606.  
  1607.      Returns the chunk size (ignoring partial chunks) in the given dimension
  1608.      for each of block, cyclic(..), and star distributions.
  1609.  
  1610.      iiii8888 ==== ddddssssmmmm____tttthhhhiiiissss____cccchhhhuuuunnnnkkkkssssiiiizzzzeeee ((((AAAA,,,, jjjj8888,,,, kkkk8888))))
  1611.  
  1612.      Returns the chunk size for the chunk containing the given index value for
  1613.      each of block, cyclic(..), and star. This value may be different from
  1614.      dsm_chunksize due to edge effects that may lead to a partial chunk.
  1615.  
  1616.      iiii8888 ==== ddddssssmmmm____rrrreeeemmmm____cccchhhhuuuunnnnkkkkssssiiiizzzzeeee ((((AAAA,,,, jjjj8888,,,, kkkk8888))))
  1617.  
  1618.      Returns the remaining chunk size from index to the end of the current
  1619.      chunk, inclusive of each end point. Essentially it is the distance from
  1620.      index to the end of that contiguous block, inclusive.
  1621.  
  1622.      iiii8888 ==== ddddssssmmmm____tttthhhhiiiissss____ssssttttaaaarrrrttttiiiinnnnggggiiiinnnnddddeeeexxxx ((((AAAA,,,, jjjj8888,,,, kkkk8888))))
  1623.  
  1624.      Returns the starting index value of the chunk containing the supplied
  1625.      index.
  1626.  
  1627.      iiii8888 ==== ddddssssmmmm____nnnnuuuummmmcccchhhhuuuunnnnkkkkssss ((((AAAA,,,, jjjj8888))))
  1628.  
  1629.      Returns the number of chunks (including partial chunks) in given dim for
  1630.      each of block, cyclic(..), and star distributions.
  1631.  
  1632.      iiii8888 ==== ddddssssmmmm____tttthhhhiiiissss____tttthhhhrrrreeeeaaaaddddnnnnuuuummmm ((((AAAA,,,, jjjj8888,,,, kkkk8888))))
  1633.  
  1634.      Returns the thread number for the chunk containing the given index value
  1635.      for each of block, cyclic(..), and star distributions.
  1636.  
  1637.      iiii8888 ==== ddddssssmmmm____ddddiiiissssttttrrrriiiibbbbuuuuttttiiiioooonnnn____bbbblllloooocccckkkk ((((AAAA,,,, jjjj8888))))
  1638.  
  1639.      iiii8888==== ddddssssmmmm____ddddiiiissssttttrrrriiiibbbbuuuuttttiiiioooonnnn____ccccyyyycccclllliiiicccc ((((AAAA,,,, jjjj8888))))
  1640.  
  1641.      iiii8888 ==== ddddssssmmmm____ddddiiiissssttttrrrriiiibbbbuuuuttttiiiioooonnnn____ssssttttaaaarrrr ((((AAAA,,,, jjjj8888))))
  1642.  
  1643.      Boolean routines to query the distribution of a given dimension.
  1644.  
  1645.  
  1646.  
  1647.                                                                        PPPPaaaaggggeeee 22225555
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  1655.  
  1656.  
  1657.  
  1658.      iiii8888 ==== ddddssssmmmm____iiiissssrrrreeeesssshhhhaaaappppeeeedddd ((((AAAA))))
  1659.  
  1660.      Boolean routine to query whether A is reshaped or not.
  1661.  
  1662.      iiii8888 ==== ddddssssmmmm____iiiissssddddiiiissssttttrrrriiiibbbbuuuutttteeeedddd ((((AAAA))))
  1663.  
  1664.      Boolean routine to query whether A is distributed (regular or reshaped)
  1665.      or not.
  1666.  
  1667.  
  1668.  
  1669.      EEEExxxxpppplllliiiicccciiiitttt PPPPllllaaaacccceeeemmmmeeeennnntttt ooooffff DDDDaaaattttaaaa
  1670.  
  1671.      For irregular data structures, you can explicitly place data in the
  1672.      physical memory of a particular processor using the following directive:
  1673.  
  1674.      c$page_place (addr, size, threadnum)
  1675.  
  1676.      where aaaaddddddddrrrr is the starting address, ssssiiiizzzzeeee is the size in bytes, and
  1677.      tttthhhhrrrreeeeaaaaddddnnnnuuuummmm is the number of the destination processor.
  1678.  
  1679.      This directive causes all the pages spanned by the virtual address range
  1680.      aaaaddddddddrrrr ((((aaaaddddddddrrrr++++ssssiiiizzzzeeee)))) to be allocated from the local memory of processor
  1681.      number tttthhhhrrrreeeeaaaaddddnnnnuuuummmm.... It is an executable statement; therefore, you can use
  1682.      it to place either statically or dynamically allocated data. An example
  1683.      of this directive is as follows:
  1684.  
  1685.      real*8 a(100)
  1686.  
  1687.      c$page_place (a, 800, 3)
  1688.  
  1689.  
  1690.  
  1691.      IIIImmmmpppplllleeeemmmmeeeennnnttttaaaattttiiiioooonnnn DDDDeeeettttaaaaiiiillllssss
  1692.  
  1693.      _C_h_a_p_t_e_r _5 of the _M_I_P_S_p_r_o _F_o_r_t_r_a_n _7_7 _P_r_o_g_r_a_m_m_e_r'_s _G_u_i_d_e describes how the
  1694.      compiler implements reshaped arrays and BBBBLLLLOOOOCCCCKKKK distribution.  It also
  1695.      describes the differences between regular and reshaped data distribution.
  1696.  
  1697.  
  1698.  
  1699.      OOOOppppttttiiiioooonnnnaaaallll EEEEnnnnvvvviiiirrrroooonnnnmmmmeeeennnntttt VVVVaaaarrrriiiiaaaabbbblllleeeessss aaaannnndddd CCCCoooommmmppppiiiilllleeee----TTTTiiiimmmmeeee OOOOppppttttiiiioooonnnnssss
  1700.  
  1701.      You can control various run-time features through the following optional
  1702.      environment variables:
  1703.  
  1704.      ____DDDDSSSSMMMM____OOOOFFFFFFFF
  1705.  
  1706.      Disables non-uniform memory access (NUMA) specific calls (for example, to
  1707.      allocate pages from a particular memory).
  1708.  
  1709.      ____DDDDSSSSMMMM____VVVVEEEERRRRBBBBOOOOSSSSEEEE
  1710.  
  1711.  
  1712.  
  1713.                                                                        PPPPaaaaggggeeee 22226666
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  1721.  
  1722.  
  1723.  
  1724.      Prints messages about parameters being used during execution.
  1725.  
  1726.      ____DDDDSSSSMMMM____PPPPPPPPMMMM
  1727.  
  1728.      Specifies the number of processors to use per memory module. Must be set
  1729.      to an integer value; to use only one processor per memory module, set
  1730.      this variable to 1.
  1731.  
  1732.      PPPPAAAAGGGGEEEESSSSIIIIZZZZEEEE____SSSSTTTTAAAACCCCKKKK,,,, PPPPAAAAGGGGEEEESSSSIIIIZZZZEEEE____DDDDAAAATTTTAAAA,,,, PPPPAAAAGGGGEEEESSSSIIIIZZZZEEEE____TTTTEEEEXXXXTTTT
  1733.  
  1734.      Specifies the desired page size in kilobytes. Must be set to an integer
  1735.      value.
  1736.  
  1737.      ____DDDDSSSSMMMM____MMMMIIIIGGGGRRRRAAAATTTTIIIIOOOONNNN
  1738.  
  1739.      Automatic page migration is OOOOFFFFFFFF by default. This variable, if set, must
  1740.      be set to one of
  1741.          OOOOFFFFFFFF diables migration entirely (default)
  1742.  
  1743.          OOOONNNN enables migration except for explicitly placed data (using
  1744.          page_place or a data distribution directive)
  1745.  
  1746.          AAAALLLLLLLL____OOOONNNN enables migration for ALL data.
  1747.  
  1748.      ____DDDDSSSSMMMM____RRRROOOOUUUUNNNNDDDD____RRRROOOOBBBBIIIINNNN
  1749.  
  1750.      Request round-robin data allocation across memories rather than first
  1751.      touch, for all of stack, data, and text segments.  Default is first-
  1752.      touch.
  1753.  
  1754.  
  1755.  
  1756.      MMMMPPPP____SSSSUUUUGGGGNNNNUUUUMMMMTTTTHHHHDDDD
  1757.  
  1758.      If set, this variable enables the use of dynamic threads in the
  1759.      multiprocessor (MP) runtime. Essentially, with dynamic threads the MP
  1760.      runtime automatically adjusts the number of threads used for a parallel
  1761.      loop at runtime based on the overall system load. This features improves
  1762.      the overall throughput of the system. Furthermore, by avoiding excessive
  1763.      concurrency, this feature can reduce delays at synchronization points
  1764.      within a single application.
  1765.  
  1766.  
  1767.      UUUUsssseeeeffffuuuullll ccccoooommmmppppiiiilllleeee----ttttiiiimmmmeeee ooooppppttttiiiioooonnnnssss
  1768.  
  1769.      The following options are part of the ----MMMMPPPP option control group supported
  1770.      by f77(1).
  1771.  
  1772.      ----MMMMPPPP::::ddddssssmmmm===={{{{oooonnnn,,,, ooooffffffff}}}} (default on)
  1773.  
  1774.      All the data-distribution and scheduling features described in this man
  1775.      page are enabled by default under ----mmmmpppp compilations. To disable all the
  1776.  
  1777.  
  1778.  
  1779.                                                                        PPPPaaaaggggeeee 22227777
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786. MMMMPPPP((((3333FFFF))))                                                                  MMMMPPPP((((3333FFFF))))
  1787.  
  1788.  
  1789.  
  1790.      DSM-specific directives (e.g. distribution and affinity scheduling),
  1791.      compile with
  1792.      ----MMMMPPPP::::ddddssssmmmm====ooooffffffff....
  1793.  
  1794.      ----MMMMPPPP::::cccclllloooonnnneeee===={{{{oooonnnn,,,, ooooffffffff}}}} (default on)
  1795.  
  1796.      The compiler automatically clones procedures that are called with
  1797.      reshaped arrays as parameters for the incoming distribution. However, if
  1798.      you have explicitly specified the distribution on all relevant formal
  1799.      parameters, then you can disable auto-cloning with -MP:clone=off. The
  1800.      consistency checking of the distribution between actual and formal
  1801.      parameters is not affected by this flag, and is always enabled.
  1802.  
  1803.      ----MMMMPPPP::::cccchhhheeeecccckkkk____rrrreeeesssshhhhaaaappppeeee===={{{{oooonnnn,,,, ooooffffffff}}}} (default off)
  1804.  
  1805.      This flag enables generation of the runtime consistency checks across
  1806.      procedure boundaries when passing reshaped arrays (or portions thereof)
  1807.      as parameters.
  1808.  
  1809.      ----MMMMPPPP::::oooolllldddd____mmmmpppp===={{{{oooonnnn,,,, ooooffffffff}}}}
  1810.  
  1811.      The -_m_p flag enables the processing of the parallel (MP) directives,
  1812.      including the original SGI/PCF directives as well as the OpenMP
  1813.      directives.  When set to off, this flag disables the processing of the
  1814.      original SGI/PCF directives but retains the processing of OpenMP
  1815.      directives.
  1816.  
  1817.      ----MMMMPPPP::::ooooppppeeeennnn____mmmmpppp===={{{{oooonnnn,,,, ooooffffffff}}}}
  1818.  
  1819.      The -_m_p flag enables the processing of the parallel (MP) directives,
  1820.      including the original SGI/PCF directives as well as the OpenMP
  1821.      directives.  When set to off, this flag disables the processing of the
  1822.      OpenMP directives but retains the processing of the original SGI/PCF
  1823.      directives.
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.      ----MMMMPPPP::::ooooppppeeeennnn____mmmmpppp===={{{{oooonnnn,,,, ooooffffffff}}}}
  1832.  
  1833.  
  1834.  
  1835. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  1836.      f77(1), sync(3f), _M_I_P_S_p_r_o _F_o_r_t_r_a_n _7_7 _P_r_o_g_r_a_m_m_e_r'_s _G_u_i_d_e _M_I_P_S_p_r_o _P_o_w_e_r
  1837.      _F_o_r_t_r_a_n _7_7 _P_r_o_g_r_a_m_m_e_r'_s _G_u_i_d_e
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.                                                                        PPPPaaaaggggeeee 22228888
  1846.  
  1847.  
  1848.  
  1849.